// import {ref} from 'vue';
// const hashPercentageRef = ref(0);

export function calculateHash(hashPercentageRef, fileChunkList) {
    return new Promise((resolve) => {
        // 添加 worker 属性
        const container = {};

        container.worker = new Worker('/hash.js');
        container.worker.postMessage({ fileChunkList });
        container.worker.onmessage = (e) => {
            const { percentage, hash } = e.data;

            hashPercentageRef.value = percentage;
            if (hash) {
                resolve(hash);
            }
        };
    });
}